/* Copyright © 2010 LPRM
Universidade Federal do Espírito Santo - RNP-GT CWTools

This file is part of GW-Android.

GW-Android is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GW-Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with GW-Android. If not, see <http://www.gnu.org/licenses/>. */
package br.ufes.cwtools.gw.android.components;

import java.util.ArrayList;

import br.ufes.cwtools.gw.android.components.RelatedComponent;

import android.os.Bundle;

public class ComponentDefinition {
	private String mTag;  // Tag que identifica unicamente este componente na aplicação.
	private String mAction;  // action para iniciar a activity pelo implicit intent
	private String mLabel;  // Label para exibir este componente no menu principal da aplicação.
	private String mPackageName;
	private String mBaseUrl;
	private Bundle mExtras;
	private ArrayList<RelatedComponent> mRelatedComponents;
	
	public ComponentDefinition(String tag, String action, String label, String packageName, String baseUrl) {
		mTag = tag;
		mAction = action;
		mLabel = label;
		mPackageName = packageName;
		mBaseUrl = baseUrl;
		mExtras = new Bundle();
		mRelatedComponents = new ArrayList<RelatedComponent>();
	}
	
	public String getTag() {
		return mTag;
	}
	
	public String getAction() {
		return mAction;
	}
	
	public String getLabel() {
		return mLabel;
	}
	
	public String getPackageName() {
		return mPackageName;
	}
	
	public String getBaseUrl() {
		return mBaseUrl;
	}
	
	public boolean showInMenu() {
		// Label vazio indica que este componente não deve ser exibido no menu principal.
		return (mLabel != null && mLabel.compareToIgnoreCase("") != 0);
	}
	
	public void putExtra(String key, String value) {
		mExtras.putString(key, value);
	}
	
	public Bundle getExtras() {
		return mExtras;
	}
	
	public void addRelatedComponent(String tag, String label, String relatedExtra) {
		final RelatedComponent relatedComponent = new RelatedComponent(tag, label, relatedExtra);
		addRelatedComponent(relatedComponent);
	}
	
	public void addRelatedComponent(RelatedComponent relatedComponent) {
		mRelatedComponents.add(relatedComponent);
	}
	
	public ArrayList<RelatedComponent> getRelatedComponents() {
		return mRelatedComponents;
	}
}